import path from 'path'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      "@": path.resolve(process.cwd(), "src"),
    }
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [],
    }),
    Components({
      resolvers: [],
    }),
  ],
  //开发配置
  server: {
    open: true, //自动打开浏览器
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:9001', // 接口域名
        changeOrigin: true,  //是否跨域
        ws: false,   //是否代理 websockets
        pathRewrite: {
          '^/api': ''    //请求的时候使用这个api就可以
        }
      },
    },
  },
})
